<?php
$options = $this->options;
$url = empty($options['url']) ? null : $options['url'];
$i = -1;
?>
<div class="table table-striped table-hover data-table">
    <table>
        <thead>
            <tr>
                <?php foreach ($this->descriptor as $key => $d): ?>
                    <th><?= $d['header']['label'] ?></th>
                <?php endforeach ?>
            </tr>
        </thead>
        <tbody>
            <?php if(count($this->parsedRows)>0): ?>
            <?php foreach ($this->parsedRows as $k => $row): ?>
                <tr class="<?= (++$i % 2 == 1) ? 'row_even' : 'row_odd' ?> <?= $row[0]['rowClass'] ?>">
                    <?php foreach ($row as $cell): ?>
                        <?php
                        $url = $cell['url'];
                        $hasUrl = $cell['urlEnable'] && $url;
                        $attributes = '';
                        if (count($cell['attributes']) > 0) {
                            foreach ($cell['attributes'] as $attrName => $attrValue) {
                                $attributes .= ' ' . $attrName . '="' . $attrValue . '"';
                            }
                        }
                        ?>
                        <td class="<?= $cell['class'] ?>" <?= $attributes ?>>
                            <?php if ($hasUrl): ?>
                                <a class="url" href="<?= $url ?>">
                            <?php endif ?>
                            <?= $cell['value'] ?>
                            <?php if ($hasUrl): ?>
                                </a>
                            <?php endif ?>
                        </td>
                    <?php endforeach ?>
                </tr>
            <?php endforeach ?>
            <?php else: ?>
                <tr class="no_data">
                    <td colspan="3">Brak danych do wyświetlenia</td>
                </tr>
            <?php endif ?>
        </tbody>
    </table>
</div>